package com.example.springbootdemo.transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService {

    @Autowired
    private UserDao userDao;

    @Transactional
    public User UpdateAndGetUserById(Integer id, String name) {
        System.out.println(userDao.findById(id));
        userDao.updateNameById(id, name);
        return userDao.findById(id);
    }
}
